/**
 * 
 */
package com.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.base.model.LoginUser;
import com.base.util.CookieWrapper;
import com.base.util.LoginUtil;
import com.model.User;

/**
 * @author leiruiqi
 *
 */
public class UserLoginUtil {

	public static String getCookieValue(HttpServletRequest req, HttpServletResponse res,String cookieName){
		if(cookieName==null){
			cookieName = "a_b_c_d";
		}
		String value = CookieWrapper.getCookieValue(req, cookieName);
		return value;
	}
	
	public static boolean validateCookie(HttpServletRequest req, HttpServletResponse res,String cookieName){
		boolean result = false;
		if(cookieName==null){
			cookieName = "a_b_c_d";
		}
		String value = CookieWrapper.getCookieValue(req, cookieName);
		if(value!=null){
			
			result = true;
			
		}
		
		return result;
	}

	public static void setCurrentUser(User user){
		LoginUtil.setCurrentUser(user);
	}
	
	public static User getCurrentUser(){
		return (User)LoginUtil.getCurrentUser();
	}
}
